package com.shenyue.nbtownlet.model;

import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.shenyue.nbtownlet.event.BaseListener;

/**
 * 通讯录
 */

public class AppContactsModel {
    private static final String ROOT = "SmallTown/XCZUser";
    private static final String ROOT_DATA = "$smalltown_xczuser_data$";
    /***获取区域ID接口****/
    public static final String GETNINGBOAREAID = "GetNingBoAreaID";
    public static final String GETNINGBOAREAID_ACTION = "$getningboareaid_action$";

    /***获取人员基本信息列表接口****/
    public static final String GETUSERINFO = "GetUserInfo_APP";
    public static final String GETUSERINFO_ACTION = "$getuserinfo_app_action$";

    /***获取人员收藏状态接口****/
    public static final String GETCOLLECTSTATUS = "GetCollectStatus";
    public static final String GETCOLLECTSTATUS_ACTION = "$getcollectstatus_action$";

    /***人员收藏接口****/
    public static final String GETISCOLLECTSUCCESS = "GetIsCollectSuccess";
    public static final String GETISCOLLECTSUCCESS_ACTION = "$getiscollectsuccess_action$";

    /***取消收藏接口****/
    public static final String GETISDELETECOLLECTSUCCESS = "GetIsDeleteCollectSuccess";
    public static final String GETISDELETECOLLECTSUCCESS_ACTION = "$getisdeletecollectsuccess_action$";

    /***获取子区域城市ID****/
    public static final String GETNEXTLEVELAREAID = "GetNextLevelAreaID_APP";
    public static final String GETNEXTLEVELAREAID_ACTION = "$getnextlevelareaid_app_action$";

    /***根据人名进行搜索（机构人员搜索）****/
    public static final String GETUSERINFOLISTBYNAME = "GetUserInfoListByName";
    public static final String GETUSERINFOLISTBYNAME_ACTION = "$getuserinfolistbyname_action$";

    /***人员收藏列表接口****/
    public static final String GETCOLLECTLIST = "GetCollectList";
    public static final String GETCOLLECTLIST_ACTION = "$getcollectlist_action$";

    /***机构列表信息接口****/
    public static final String GETMAINORGANIZATIONINFO = "GetMainOrganizationInfo";
    public static final String GETMAINORGANIZATIONINFO_ACTION = "$getmainorganizationinfo_action$";

    public static void GetNingBoAreaID(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + ROOT + "/" + GETNINGBOAREAID, GETNINGBOAREAID_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                JSONObject data = JSON.parseObject(val);
                AppModel.setNingBoAreaID(context, data.getString("areaid"));
                AppModel.setAreaId(context, data.getString("areaid"));
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    public static void GetUserInfo(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + ROOT + "/" + GETUSERINFO, GETUSERINFO_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    public static void GetCollectStatus(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + ROOT + "/" + GETCOLLECTSTATUS, GETCOLLECTSTATUS_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    public static void GetIsCollectSuccess(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + ROOT + "/" + GETISCOLLECTSUCCESS, GETISCOLLECTSUCCESS_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    public static void GetIsDeleteCollectSuccess(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + ROOT + "/" + GETISDELETECOLLECTSUCCESS, GETISDELETECOLLECTSUCCESS_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    public static void GetNextLevelAreaID(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + ROOT + "/" + GETNEXTLEVELAREAID, GETNEXTLEVELAREAID_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    public static void GetUserInfoListByName(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + ROOT + "/" + GETUSERINFOLISTBYNAME, GETUSERINFOLISTBYNAME_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    public static void GetCollectList(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + ROOT + "/" + GETCOLLECTLIST, GETCOLLECTLIST_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    public static void GetMainOrganizationInfo(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + ROOT + "/" + GETMAINORGANIZATIONINFO, GETMAINORGANIZATIONINFO_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }
}
